<?php


class SetorDAO extends Setor {

    public function listar() {
        $pdo = new ConnectionFactory();
        $conexao = $pdo->getConnection();
        $query = $conexao->prepare('select * from PROFISSAO ');
        $query->execute();
        $dados = array();
        while ($linha = $query->fetch(PDO::FETCH_ASSOC)) {
            $dados[] = $linha;
        }
        return $dados;
    }

    public function incluir() {
        $pdo = new ConnectionFactory();
        $conexao = $pdo->getConnection();
        try {
            $conexao->beginTransaction();
            $query = $conexao->prepare('insert into PROFISSAO(DESCRICAO,ATIVO) values (?,?) ');
            $query->bindParam(1, parent::__get('descricao'), PDO::PARAM_STR, 45);
            $query->bindParam(2, parent::__get('ativo'), PDO::PARAM_STR, 1);
            $query->execute();
            $conexao->commit();
        } catch (Exception $e) {
            $conexao->rollback();
        }
    }

}

?>
